/*
							Copyright (C) 2010  Alourien Team
									
						This file is part of the Alourien Engine.

    The Alourien Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    The Alourien Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with the Alourien Engine.  If not, see <http://www.gnu.org/licenses/>.
	
 *File Name: VectorMathimp.cpp
 *Programmer Name:Jose Castellano
 *Date of last update:10/27/2010
 *
 *Purpose:This Program is to create and Manipulate all the vectors 
 * that are needed for all the work that is used involving 
 * the vectors.
 *
 *Basic Info: This file includes the overloaded operator for addition 
 * both dimensions, overloaded operator for multiplication, overloaded
 * dot product,and cross product. The headers that will be
 * required in this would be Vector2D, Vector3D, and VectorMath.
 *
 *UPDATES:
 *1)Created the Program and documentation.
 *  Date:10/1/2010 Updater: Jose Castellano
 *
 *2) Added the actual code to our Engine namespace
 *   Date: 10/06/2010 Updater: Manuel Cuellar
 *
 *3) Added the normalize methods to the program
 *	 Date: 10/07/2010 Updater: Jose Castellano
 *
 *
 */

#include "VectorMath.h"
#include "Vector2D.h"
#include "Vector3D.h"

namespace Alourien
{
	VectorMath::VectorMath(void)
	{
	}


	VectorMath::~VectorMath(void)
	{
	}

	//Finds the dot product of two vectors
	//Returns an float
	float VectorMath::DotProduct(Vector2D vector1, Vector2D vector2)
	{
		return vector1.x*vector2.x + vector1.y*vector2.y;
	}

	//Overload of dotProduct, but with 3 Dimensional Vectors
	//Returns an float
	float VectorMath::DotProduct(Vector3D vector1, Vector3D vector2)
	{
		return vector1.x*vector2.x + vector1.y*vector2.y + vector1.z*vector2.z;
	}

	//Finds the cross product of two vectors
	//Returns a 3 dimensional vector
	Vector3D VectorMath::CrossProduct(Vector3D vector1, Vector3D vector2)
	{
		Vector3D tempData;

		tempData.x = ((vector1.y * vector2.z) - (vector2.y * vector1.z));
		tempData.y = ((vector1.z * vector2.x) - (vector2.z * vector1.x));
		tempData.z = ((vector1.x * vector2.y) - (vector2.x * vector1.y));

		return tempData;
	}
	
	//Normalizes a vector to get the unit vector magnitude
	//Uses the magnitude found from the pythagorean theorum
	Vector2D VectorMath::NormalizeVector2D(Vector2D vector, float magnitude)
	{
		Vector2D temp;
	
		temp.x = vector.x / magnitude;
		temp.y = vector.y / magnitude;
	
		return temp;
	}

	//Normalizes a vector to get the unit vector magnitude
	//Uses the magnitude found from the pythagorean theorum
	Vector3D VectorMath::NormalizeVector3D(Vector3D vector, float magnitude)
	{	
		Vector3D temp;
	
		temp.x = vector.x / magnitude;
		temp.y = vector.y / magnitude;
		temp.z = vector.z / magnitude;
		
		return temp;
	}
}

